﻿package com.wandian.util
{
	import flash.events.ContextMenuEvent;
	import flash.ui.ContextMenu;
	import flash.ui.ContextMenuBuiltInItems;
	import flash.ui.ContextMenuItem;
	/**   
	* @author long
	* @QQ 108232706
	* @version 1.0   
	*/   
	public class ContextMenuPlus extends Object
	{
		private var _contextMenu:ContextMenu;

		public function ContextMenuPlus(param1:Boolean=true, param2:Function=null, ... args)
		{
			this._contextMenu=new ContextMenu();
			if (param1)
			{
				this.removeDefault();
			}
			if (args.length > 0)
			{
			}
			if (param2 != null)
			{
				this.addCustomItems(param2, args);
			}
			return;
		} 

		public function get contextMenu():ContextMenu
		{
			return this._contextMenu;
		} 

		public function get builtInItems():ContextMenuBuiltInItems
		{
			return this._contextMenu.builtInItems;
		} 

		public function removeDefault(... args):void
		{
			/*--------- var _loc_3:String = null;
			 this._contextMenu.hideBuiltInItems();
			 if (args.length == 0)
			 {
				 return;
			 }
			 args = this._contextMenu.builtInItems;
			 for each (_loc_3 in args)
			 {

				 args[_loc_3] = true;
			 }*/
			return;
		} 

		public function addCustom(param1:Function, param2:String, param3:Boolean=false, param4:Boolean=true, param5:Boolean=true):void
		{
			var _loc_6:*=new ContextMenuItem(param2, param3, param4, param5);
			this._contextMenu.customItems.push(_loc_6);
			_loc_6.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT, param1);
			return;
		} 

		public function addGroup(param1:Function, param2:Boolean=false, ... args):void
		{
			this.addCustomItems(param1, args, param2);
			return;
		} 

		private function addCustomItems(param1:Function, param2:Array, param3:Boolean=false):void
		{
			var _loc_5:String=null;
			if (param2.length == 1)
			{
			}
			var _loc_4:*=param2[0] is Array ? (param2[0]) : (param2);
			for each (_loc_5 in _loc_4)
			{

				this.addCustom(param1, _loc_5, param3);
				if (param3)
				{
					param3=false;
				}
			}
			return;
		} 

	}
}
